package com.jianshuai.fallback;

import com.jianshuai.domain.Device;
import com.jianshuai.feign.DeviceFeignClient;
import feign.hystrix.FallbackFactory;
import org.aspectj.lang.reflect.Advice;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class DeviceFeignClientFallback implements FallbackFactory<DeviceFeignClient> {


    @Override
    public DeviceFeignClient create(Throwable throwable) {
        return new DeviceFeignClient() {
            @Override
            public List<Device> getByBuildId(Long id) {
                List<Device> devices = new ArrayList<>();
                devices.add(new Device(-1L,"触发了降级!!!"));
                return devices;
            }

            @Override
            public List<Device> getDeviceListByDeviceType(Long type) {
                List<Device> devices = new ArrayList<>();
                devices.add(new Device(-1L,"触发了降级!!!"));
                return devices;
            }
        };
    }
}
